package nu.aing.P20140616;

/**
 * FULL NYONTEK ! KAGAK NGARTI KENAPA BEGINI !
 * 
 * @author memekmaut@gmail.com
 */
public class CatAndRat {
    
    public static void main(String[] args) {
        CatAndRat obj = new CatAndRat();
        System.out.println(obj.getTime(10, 1, 1, 1) );
        System.out.println(obj.getTime(10, 1, 1, 2) );
        System.out.println(obj.getTime(10, 1, 2, 1) );
        System.out.println(obj.getTime(1000, 1000, 1, 1000) );
        System.out.println(obj.getTime(1, 1000, 1, 2) );
    }
    
    /**
     * @param R - Tube radius
     * @param T - cat enter the tube via same entrance.
     * @param Vrat - Rat speed.
     * @param Vcat - Cat speed.
     */
    public double getTime(int R, int T, int Vrat, int Vcat) {
        if(Vrat >= Vcat) {
            return -1l;
        }
        
        /**
         * Luas lingkaran
         */
        double circle_length = 2 * Math.PI * R;
        /**
         * Rat distance = speed * T
         */
        double rat_distance = Vrat * T;
        /**
         * Ini buat apaan sih? keren bener ada rumusnye..
         */
        double idist = Math.min(circle_length / 2, rat_distance);
        
        /**
         * kampret lah..
         */
        return idist / (Vrat - Vcat);
    }
}
